package com.fumihiko.modules.jxxm.service.impl;

import com.fumihiko.modules.jxxm.entity.AdjustmentBasisEntity;
import com.fumihiko.modules.jxxm.service.AdjustmentBasisService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fumihiko.common.utils.PageUtils;
import com.fumihiko.common.utils.Query;

import com.fumihiko.modules.jxxm.dao.RetiredEmployeesDao;
import com.fumihiko.modules.jxxm.entity.RetiredEmployeesEntity;
import com.fumihiko.modules.jxxm.service.RetiredEmployeesService;


@Service("retiredEmployeesService")
public class RetiredEmployeesServiceImpl extends ServiceImpl<RetiredEmployeesDao, RetiredEmployeesEntity> implements RetiredEmployeesService {
    @Autowired
    private AdjustmentBasisService adjustmentBasisService;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        String myStatus = (String)params.get("myStatus");
        String name = (String)params.get("name");
        String idNo = (String)params.get("idNo");
        String personType = (String)params.get("personType");
        String originalTroops = (String)params.get("originalTroops");
        String retirementStatus = (String)params.get("retirementStatus");
        String duties = (String)params.get("duties");
        String county = (String)params.get("county");
        String street = (String)params.get("street");
        String birthDate1 = (String)params.get("birthDate1");
        String birthDate2 = (String)params.get("birthDate2");
        String age1 = (String)params.get("age1");
        String age2 = (String)params.get("age2");
        String retirementTime1 = (String)params.get("retirementTime1");
        String retirementTime2 = (String)params.get("retirementTime2");
        String workTime1 = (String)params.get("workTime1");
        String workTime2 = (String)params.get("workTime2");
        IPage<RetiredEmployeesEntity> page = this.page(
                new Query<RetiredEmployeesEntity>().getPage(params),
                new QueryWrapper<RetiredEmployeesEntity>().
                        eq("state",0).
                        like(StringUtils.isNotBlank(myStatus),"my_status", myStatus).
                        like(StringUtils.isNotBlank(name),"name", name).
                        eq(StringUtils.isNotBlank(idNo),"id_no",idNo).
                        eq(StringUtils.isNotBlank(personType),"person_type",personType).
                        like(StringUtils.isNotBlank(originalTroops),"original_troops", originalTroops).
                        like(StringUtils.isNotBlank(retirementStatus),"retirement_status", retirementStatus).
                        like(StringUtils.isNotBlank(duties),"duties",duties).
                        like(StringUtils.isNotBlank(county),"county", county).
                        like(StringUtils.isNotBlank(street),"street", street).
                        ge(StringUtils.isNotBlank(birthDate1),"birth_date", birthDate1).
                        le(StringUtils.isNotBlank(birthDate2),"birth_date", birthDate2).
                        ge(StringUtils.isNotBlank(retirementTime1),"retirement_time", retirementTime1).
                        le(StringUtils.isNotBlank(retirementTime2),"retirement_time", retirementTime2).
                        ge(StringUtils.isNotBlank(workTime1),"work_time", workTime1).
                        le(StringUtils.isNotBlank(workTime2),"work_time", workTime2).orderByAsc("id")
        );
        return new PageUtils(page);
    }

    @Override
    public PageUtils searchPage(Map<String, Object> params) {
        String myStatus = (String)params.get("myStatus");
        String name = (String)params.get("name");
        String idNo = (String)params.get("idNo");
        String personType = (String)params.get("personType");
        String originalTroops = (String)params.get("originalTroops");
        String retirementStatus = (String)params.get("retirementStatus");
        String duties = (String)params.get("duties");
        String county = (String)params.get("county");
        String street = (String)params.get("street");
        String birthDate1 = (String)params.get("birthDate1");
        String birthDate2 = (String)params.get("birthDate2");
        String age1 = (String)params.get("age1");
        String age2 = (String)params.get("age2");
        String retirementTime1 = (String)params.get("retirementTime1");
        String retirementTime2 = (String)params.get("retirementTime2");
        String workTime1 = (String)params.get("workTime1");
        String workTime2 = (String)params.get("workTime2");
        IPage<RetiredEmployeesEntity> page = this.page(
                new Query<RetiredEmployeesEntity>().getPage(params),
                new QueryWrapper<RetiredEmployeesEntity>().
                        eq("state",0).
                        like(StringUtils.isNotBlank(myStatus),"my_status", myStatus).
                        like(StringUtils.isNotBlank(name),"name", name).
                        eq(StringUtils.isNotBlank(idNo),"id_no",idNo).
                        eq(StringUtils.isNotBlank(personType),"person_type",personType).
                        like(StringUtils.isNotBlank(originalTroops),"original_troops", originalTroops).
                        like(StringUtils.isNotBlank(retirementStatus),"retirement_status", retirementStatus).
                        like(StringUtils.isNotBlank(duties),"duties",duties).
                        like(StringUtils.isNotBlank(county),"county", county).
                        like(StringUtils.isNotBlank(street),"street", street).
                        ge(StringUtils.isNotBlank(birthDate1),"birth_date", birthDate1).
                        le(StringUtils.isNotBlank(birthDate2),"birth_date", birthDate2).
                        ge(StringUtils.isNotBlank(retirementTime1),"retirement_time", retirementTime1).
                        le(StringUtils.isNotBlank(retirementTime2),"retirement_time", retirementTime2).
                        ge(StringUtils.isNotBlank(workTime1),"work_time", workTime1).
                        le(StringUtils.isNotBlank(workTime2),"work_time", workTime2).orderByAsc("id")
        );
        return new PageUtils(page);
    }
    @Override
    public List<RetiredEmployeesEntity> queryErrorPage(Map<String, Object> params) {
        List<RetiredEmployeesEntity> list = new ArrayList<>();
        List<RetiredEmployeesEntity> listAll = baseMapper.getAllList();

        for (int i = 0; i <listAll.size() ; i++) {
            RetiredEmployeesEntity retiredEmployeesEntity = new RetiredEmployeesEntity();
            RetiredEmployeesEntity re = listAll.get(i);
            //基本信息
            retiredEmployeesEntity.setPersonalCode(re.getPersonalCode());
            retiredEmployeesEntity.setName(re.getName());
            retiredEmployeesEntity.setTotalMonthlyPension(re.getTotalMonthlyPension());
            retiredEmployeesEntity.setWorkersClassification(re.getWorkersClassification());
            retiredEmployeesEntity.setCounty(re.getCounty());
            retiredEmployeesEntity.setStreet(re.getStreet());
            retiredEmployeesEntity.setHandoverPeriod(re.getHandoverPeriod());
            retiredEmployeesEntity.setDeath("错误");
            //退休费基数
            Double salaryScale = re.getSalaryScale();//薪级工资
            Double basicSalary = re.getBasicSalary();//基础工资
            Double raiseWages = re.getRaiseWages();//提高工资10%
            Double serviceAllowance = re.getServiceAllowance();//军队服务津贴
            Double difficultySubsidy = re.getDifficultySubsidy();//困难补助
            Double gradeSalary = re.getGradeSalary();//岗位工资
            Double senioritySalary = re.getSenioritySalary();//工龄工资
            Double levelSalary = re.getLevelSalary();//级别工资
            Double bonusAllowance = re.getBonusAllowance();//奖金津贴
            Double seniorityAllowance = re.getSeniorityAllowance();//教护龄津贴
            Double specialTeacherSubsidy = re.getSpecialTeacherSubsidy();//特级老师补贴
            //退休费计发比例
            int txfjfbl = re.getRetirementFeeProportion();
            //提高比例部分
            int tgblbf = re.getIncreaseProportion();
            //工资是否提高10%
            String gzsftg = re.getIsImprove();
            int gzsftgValue = 0;
            if(gzsftg.equals("是"))
            {
                gzsftgValue = 10;
            }
            txfjfbl = txfjfbl + tgblbf + gzsftgValue;

            Double bl = Double.valueOf(txfjfbl);
            bl = bl/100;
            Double sumBasicRe = gradeSalary + salaryScale + serviceAllowance + bonusAllowance + raiseWages + levelSalary;
            sumBasicRe = Math.ceil(sumBasicRe * bl);
            sumBasicRe = sumBasicRe + basicSalary + difficultySubsidy + senioritySalary + seniorityAllowance + specialTeacherSubsidy;

            retiredEmployeesEntity.setResultA(Double.valueOf(String.format("%.2f", sumBasicRe )));
            //历次增加的退休费合计
            Double retirementPayEightynine = re.getRetirementPayEightynine();//1989年10月增加退休费
            Double retirementPayNinetyfive = re.getRetirementPayNinetyfive();//1995年10月增加退休费
            Double retirementPayNinetynisec = re.getRetirementPayNinetynisec();//1999年10月增加退休费
            Double retirementPayThisec = re.getRetirementPayThisec();//2003年10月增加退休费
            Double retirementPayFirst = re.getRetirementPayFirst();//1993年10月第一步增加退休费
            Double retirementPayNinetyseven = re.getRetirementPayNinetyseven();//1997年7月增加退休费
            Double retirementPayOne = re.getRetirementPayOne();//2001年1月增加退休费
            Double retirementPayThird = re.getRetirementPayThird();//2003年7月增加退休费
            Double retirementPayFourty = re.getRetirementPayFourty();//2014年10月增加退休费
            Double retirementPayNinetytwo = re.getRetirementPayNinetytwo();//1992年3月提高退休费10％
            Double retirementPayNinetysesec = re.getRetirementPayNinetysesec();//1997年10月增加退休费
            Double retirementPayOnsec = re.getRetirementPayOnsec();//2001年10月增加退休费
            Double retirementPayFive = re.getRetirementPayFive();//2005年10月增加退休费
            Double retirementPaySecond = re.getRetirementPaySecond();//1993年10月第二步增加退休费
            Double retirementPayNinetynine = re.getRetirementPayNinetynine();//1999年7月增加退休费
            Double retirementPayOnenew = re.getRetirementPayOnenew();//2001年10月新增退休费
            Double retirementPaySix = re.getRetirementPaySix();//2006年7月增加退休费
            Double sumAddRe = retirementPayEightynine+retirementPayNinetyfive+retirementPayNinetynisec+retirementPayThisec+retirementPayFirst+
                    retirementPayNinetyseven+retirementPayOne+retirementPayThird+retirementPayFourty+retirementPayNinetytwo+retirementPayNinetysesec+
                    retirementPayOnsec+retirementPayFive+retirementPaySecond+retirementPayNinetynine+retirementPayOnenew+retirementPaySix;//历次增加的退休费合计
            retiredEmployeesEntity.setResultB(Double.valueOf(String.format("%.2f", sumAddRe )));
            //价格生活补贴合计
            Double foodAllowanceSeventynine = re.getFoodAllowanceSeventynine();
            Double oilAllowanceNightyone = re.getOilAllowanceNightyone();
            Double fuelLlowance = re.getFuelLlowance();
            Double oilAllowanceNightythird = re.getOilAllowanceNightythird();
            Double livingAllowanceEightyei = re.getLivingAllowanceEightyei();
            Double livingAllowanceNightyfo = re.getLivingAllowanceNightyfo();
            Double foodAllowanceEightyeight = re.getFoodAllowanceEightyeight();
            Double oilAllowanceNightytwo = re.getOilAllowanceNightytwo();
            Double meatLlowance = re.getMeatLlowance();
            Double livingAllowanceEightyfive = re.getLivingAllowanceEightyfive();
            Double livingAllowanceNightytw = re.getLivingAllowanceNightytw();
            Double livingAllowanceNightyfive = re.getLivingAllowanceNightyfive();
            Double sumPrice = foodAllowanceSeventynine + oilAllowanceNightyone + fuelLlowance + oilAllowanceNightythird +
                    livingAllowanceEightyei + livingAllowanceNightyfo + foodAllowanceEightyeight +
                    oilAllowanceNightytwo + meatLlowance + livingAllowanceEightyfive + livingAllowanceNightytw + livingAllowanceNightyfive;//价格生活补贴合计
            retiredEmployeesEntity.setResultC(Double.valueOf(String.format("%.2f", sumPrice )));
            //增加生活机制（补贴）合计
            Double livingAllowanceSeven = re.getLivingAllowanceSeven();
            Double jobSubsidy = re.getJobSubsidy();
            Double ageAllowance = re.getAgeAllowance();
            Double retirementAllowanceOneo = re.getRetirementAllowanceOneo();
            Double workingYearsSubsidy = re.getWorkingYearsSubsidy();
            Double proportionalSubsidy = re.getProportionalSubsidy();
            Double growthMechanismThirty = re.getGrowthMechanismThirty();
            Double retirementAllowanceOneth = re.getRetirementAllowanceOneth();
            Double retirementAllowanceThirty = re.getRetirementAllowanceThirty();
            Double pensionSixteen = re.getPensionSixteen();
            Double pensionSeventeen = re.getPensionSeventeen();
            Double pensionEighteen = re.getPensionEighteen();
            Double pensionNineteen = re.getPensionNineteen();
            Double adjustTreatment = re.getAdjustTreatment();
            Double pensionTwenty = re.getPensionTwenty();
            Double pensionTwentyone = re.getPensionTwentyone();
            Double sumMeleft = livingAllowanceSeven + jobSubsidy + ageAllowance + retirementAllowanceOneo + workingYearsSubsidy + proportionalSubsidy +
                    growthMechanismThirty + retirementAllowanceOneth + retirementAllowanceThirty + pensionSixteen + pensionSeventeen + pensionEighteen +
                    pensionNineteen + adjustTreatment + pensionTwenty + pensionTwentyone;
            retiredEmployeesEntity.setResultF(Double.valueOf(String.format("%.2f", sumMeleft )));
            //其它合计
            Double paperMoney = re.getPaperMoney();
            Double bathSubsidy = re.getBathSubsidy();
            Double housingSubsidy = re.getHousingSubsidy();
            Double otherIncome = re.getOtherIncome();
            Double honorAllowance = re.getHonorAllowance();
            Double serviceSubsidy = re.getServiceSubsidy();
            Double sumOther = paperMoney + bathSubsidy + housingSubsidy + otherIncome + honorAllowance + serviceSubsidy;
            retiredEmployeesEntity.setResultG(Double.valueOf(String.format("%.2f", sumOther )));
            //自动生成退休费
            Double sum = sumBasicRe + sumAddRe + sumPrice + sumMeleft + sumOther;
            retiredEmployeesEntity.setResultH(Double.valueOf(String.format("%.2f", sum)));
            //退休费的差额
            Double total = re.getTotalMonthlyPension();
            Double sumC = total - sum;
            retiredEmployeesEntity.setResultI(Double.valueOf(String.format("%.2f", sumC)));
            if(sumC >0 || sumC <0)
            {
                list.add(retiredEmployeesEntity);
            }

        }

        return list;
    }

    @Override
    public void updateResult() throws ParseException {
        List<RetiredEmployeesEntity> listAll = baseMapper.getResultList();

        for (int i = 0; i <listAll.size(); i++) {
            RetiredEmployeesEntity retiredEmployeesEntity = new RetiredEmployeesEntity();
            RetiredEmployeesEntity re = listAll.get(i);
            //基本信息
            retiredEmployeesEntity.setId(re.getId());

            Double totalMonthlyPension = re.getTotalMonthlyPension();
            Double pensionTwentyone = re.getPensionTwentyone();
            Double sum = totalMonthlyPension + pensionTwentyone;

            retiredEmployeesEntity.setTotalMonthlyPension(sum);

            if(re.getMyStatus().equals("在世"))
            {
                Double first = 36.00;
                Double second = 0.00;
                if(re.getWorkingYears() < 10)
                {
                    second = 30.00;
                }else
                {
                    second = re.getWorkingYears() * 3 + re.getYuYue() * 0.25;
                }
                Double third = 0.00;
                Double ylj = re.getTotalMonthlyPension() +re.getPensionTwentyone() - re.getServiceSubsidy();
                if(ylj < 6250)
                {
                    third = 50.00;
                }else if(ylj >= 6250 && ylj <= 6280)
                {
                    third = 6300 - ylj;
                }else
                {
                    third = 20.00;
                }
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                Double four = 0.00;
                String birthday = sdf.format(re.getBirthDate());
                int year = Integer.valueOf(birthday.substring(0,4));
                if(2021-year < 65)
                {
                    four = 0.00;
                }else if(2021-year >=65 && 2021-year < 70)
                {
                    if(re.getWorkingYears() >= 30)
                    {
                        four = 45.00;
                    }else
                    {
                        four = 40.00;
                    }
                }else if(2021-year >=70 && 2021-year < 75)
                {
                    if(re.getWorkingYears() >= 30)
                    {
                        four = 55.00;
                    }else
                    {
                        four = 50.00;
                    }
                }else if(2021-year >=75 && 2021-year < 80)
                {
                    if(re.getWorkingYears() >= 30)
                    {
                        four = 65.00;
                    }else
                    {
                        four = 60.00;
                    }
                }else if(2021-year >=80)
                {
                    if(re.getWorkingYears() >= 30)
                    {
                        four = 75.00;
                    }else
                    {
                        four = 70.00;
                    }
                }
                retiredEmployeesEntity.setExt1(first+second+third+four);
            }else
            {
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
                Date date1 = sdf1.parse("2022-01-01");
                if(re.getDeathTime().compareTo(date1) >=0)
                {
                    Double first = 36.00;
                    Double second = 0.00;
                    if(re.getWorkingYears() < 10)
                    {
                        second = 30.00;
                    }else
                    {
                        second = re.getWorkingYears() * 3 + re.getYuYue() * 0.25;
                    }
                    Double third = 0.00;
                    Double ylj = re.getTotalMonthlyPension()+re.getPensionTwentyone() - re.getServiceSubsidy();
                    if(ylj < 6250)
                    {
                        third = 50.00;
                    }else if(ylj >= 6250 && ylj <= 6280)
                    {
                        third = 6300 - ylj;
                    }else
                    {
                        third = 20.00;
                    }
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    Double four = 0.00;
                    String birthday = sdf.format(re.getBirthDate());
                    int year = Integer.valueOf(birthday.substring(0,4));
                    if(2021-year < 65)
                    {
                        four = 0.00;
                    }else if(2021-year >=65 && 2021-year < 70)
                    {
                        if(re.getWorkingYears() >= 30)
                        {
                            four = 45.00;
                        }else
                        {
                            four = 40.00;
                        }
                    }else if(2021-year >=70 && 2021-year < 75)
                    {
                        if(re.getWorkingYears() >= 30)
                        {
                            four = 55.00;
                        }else
                        {
                            four = 50.00;
                        }
                    }else if(2021-year >=75 && 2021-year < 80)
                    {
                        if(re.getWorkingYears() >= 30)
                        {
                            four = 65.00;
                        }else
                        {
                            four = 60.00;
                        }
                    }else if(2021-year >=80)
                    {
                        if(re.getWorkingYears() >= 30)
                        {
                            four = 75.00;
                        }else
                        {
                            four = 70.00;
                        }
                    }
                    retiredEmployeesEntity.setExt1(first+second+third+four);
                }else
                {
                    retiredEmployeesEntity.setExt1(0.00);
                }

            }

          updateById(retiredEmployeesEntity);

        System.out.println("姓名："+re.getName()+" 个人编码："+re.getPersonalCode()+" 2022年退休金："+retiredEmployeesEntity.getExt1()+" 月退休金总额："+sum + " 序号"+i);

        }
    }

    @Override
    public PageUtils queryDeathPensionPage(Map<String, Object> params) {


        IPage<RetiredEmployeesEntity> page = this.page(
                new Query<RetiredEmployeesEntity>().getPage(params),
                new QueryWrapper<RetiredEmployeesEntity>().
                        eq("state",0).eq("my_status","死亡").
                ge("death_time","2022-01-01")
        );
        List<RetiredEmployeesEntity> list = new ArrayList<>();
        for (int i = 0; i <page.getRecords().size() ; i++) {
            RetiredEmployeesEntity retiredEmployeesEntity = new RetiredEmployeesEntity();
            RetiredEmployeesEntity re = page.getRecords().get(i);


            retiredEmployeesEntity.setPersonalCode(re.getPersonalCode());
            retiredEmployeesEntity.setName(re.getName());
            retiredEmployeesEntity.setSex(re.getSex());
            retiredEmployeesEntity.setBirthDate(re.getBirthDate());
            retiredEmployeesEntity.setWorkTime(re.getWorkTime());
            retiredEmployeesEntity.setRetirementTime(re.getRetirementTime());
            retiredEmployeesEntity.setRetirementStatus(re.getRetirementStatus());
            retiredEmployeesEntity.setDuties(re.getDuties());
            retiredEmployeesEntity.setCounty(re.getCounty());
            retiredEmployeesEntity.setStreet(re.getStreet());
            retiredEmployeesEntity.setHandoverPeriod(re.getHandoverPeriod());
            retiredEmployeesEntity.setWorkersClassification(re.getWorkersClassification());
            retiredEmployeesEntity.setDeathTime(re.getDeathTime());
            String gL = re.getWorkingYears()+"年"+re.getYuYue()+"个月";
            retiredEmployeesEntity.setPhone(gL);
            retiredEmployeesEntity.setExt1(re.getExt1());

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String sj = sdf.format(re.getDeathTime());
            String bfys = sj.substring(5,7);
            retiredEmployeesEntity.setAddress(bfys);
            int yf = Integer.valueOf(bfys);
            Double bfhj = yf*re.getExt1();
            retiredEmployeesEntity.setExt2(bfhj);

            list.add(retiredEmployeesEntity);
        }

        page.setRecords(list);
        return new PageUtils(page);
    }

    @Override
    public List<RetiredEmployeesEntity> listDeathPensionExcel(Map<String, Object> params) {
        QueryWrapper<RetiredEmployeesEntity>  queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("state",0);
        queryWrapper.eq("my_status","死亡");
        queryWrapper.ge("death_time", "2022-01-01");

        List<RetiredEmployeesEntity> listAll = baseMapper.listDeathPensionExcel(queryWrapper);
        List<RetiredEmployeesEntity> list = new ArrayList<>();
        for (int i = 0; i < listAll.size(); i++) {
            RetiredEmployeesEntity retiredEmployeesEntity = new RetiredEmployeesEntity();
            RetiredEmployeesEntity re =listAll.get(i);


            retiredEmployeesEntity.setPersonalCode(re.getPersonalCode());
            retiredEmployeesEntity.setName(re.getName());
            retiredEmployeesEntity.setSex(re.getSex());
            retiredEmployeesEntity.setBirthDate(re.getBirthDate());
            retiredEmployeesEntity.setWorkTime(re.getWorkTime());
            retiredEmployeesEntity.setRetirementTime(re.getRetirementTime());
            retiredEmployeesEntity.setRetirementStatus(re.getRetirementStatus());
            retiredEmployeesEntity.setDuties(re.getDuties());
            retiredEmployeesEntity.setCounty(re.getCounty());
            retiredEmployeesEntity.setStreet(re.getStreet());
            retiredEmployeesEntity.setHandoverPeriod(re.getHandoverPeriod());
            retiredEmployeesEntity.setWorkersClassification(re.getWorkersClassification());
            retiredEmployeesEntity.setDeathTime(re.getDeathTime());
            String gL = re.getWorkingYears()+"年"+re.getYuYue()+"个月";
            retiredEmployeesEntity.setPhone(gL);
            retiredEmployeesEntity.setExt1(re.getExt1());

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String sj = sdf.format(re.getDeathTime());
            String bfys = sj.substring(5,7);
            retiredEmployeesEntity.setAddress(bfys);
            int yf = Integer.valueOf(bfys);
            Double bfhj = yf*re.getExt1();
            retiredEmployeesEntity.setExt2(bfhj);

            list.add(retiredEmployeesEntity);
        }


        return list;
    }

    @Override
    public PageUtils queryAddPensionPage(Map<String, Object> params) {
        IPage<RetiredEmployeesEntity> page = this.page(
                new Query<RetiredEmployeesEntity>().getPage(params),
                new QueryWrapper<RetiredEmployeesEntity>().
                        eq("state",0).eq("my_status","在世")

        );
        AdjustmentBasisEntity adjustmentBasis = adjustmentBasisService.getInfoList();
        List<RetiredEmployeesEntity> list = new ArrayList<>();
        for (int i = 0; i <page.getRecords().size() ; i++) {
            RetiredEmployeesEntity retiredEmployeesEntity = new RetiredEmployeesEntity();
            RetiredEmployeesEntity re = page.getRecords().get(i);

            retiredEmployeesEntity.setId(re.getId());
            retiredEmployeesEntity.setPersonalCode(re.getPersonalCode());
            retiredEmployeesEntity.setName(re.getName());
            retiredEmployeesEntity.setSex(re.getSex());
            retiredEmployeesEntity.setBirthDate(re.getBirthDate());
            retiredEmployeesEntity.setWorkTime(re.getWorkTime());
            retiredEmployeesEntity.setRetirementTime(re.getRetirementTime());
            retiredEmployeesEntity.setDuties(re.getDuties());
            retiredEmployeesEntity.setCounty(re.getCounty());
            retiredEmployeesEntity.setStreet(re.getStreet());
            retiredEmployeesEntity.setHandoverPeriod(re.getHandoverPeriod());
            retiredEmployeesEntity.setHandoverTime(re.getHandoverTime());
            retiredEmployeesEntity.setWorkersClassification(re.getWorkersClassification());
            retiredEmployeesEntity.setTotalMonthlyPension(re.getTotalMonthlyPension());
            retiredEmployeesEntity.setExt1(re.getExt1());
            retiredEmployeesEntity.setExt3(re.getExt1()+re.getTotalMonthlyPension());
            retiredEmployeesEntity.setYuYue(adjustmentBasis.getBfys());
            double f = adjustmentBasis.getBfys()*re.getExt1();
            BigDecimal bfj = new BigDecimal(f);
            double bf = bfj.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            retiredEmployeesEntity.setExt2(bf);

            double s = retiredEmployeesEntity.getExt3()+retiredEmployeesEntity.getExt2();
            BigDecimal je = new BigDecimal(s);
            double sf = je.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            retiredEmployeesEntity.setExt4(sf);

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
            Date date = new Date();
            int year = Integer.valueOf(sdf.format(date));
            int birthday = Integer.valueOf(sdf.format(re.getBirthDate()));
            int result = year - birthday;
            retiredEmployeesEntity.setHousingArea(result);

            SimpleDateFormat two = new SimpleDateFormat("yyyy-MM-dd");
            if(re.getWorkTime() != null && re.getRetirementTime() != null)
            {
                String date1 = two.format(re.getWorkTime());
                String date2 = two.format(re.getRetirementTime());
                LocalDate date3 = LocalDate.parse(date1);
                LocalDate date4 = LocalDate.parse(date2);
                int yu = (int)ChronoUnit.MONTHS.between(date3,date4);
                int a = yu / 12;
                int b = yu % 12;
                String pc = a+"年"+b+"月";
                retiredEmployeesEntity.setCommunity(pc);
            }else
            {
                retiredEmployeesEntity.setCommunity("");
            }

            list.add(retiredEmployeesEntity);
        }

        page.setRecords(list);
        return new PageUtils(page);
    }

    @Override
    public List<RetiredEmployeesEntity> listAddPensionExcel(Map<String, Object> params) {
        QueryWrapper<RetiredEmployeesEntity>  queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("state",0);
        queryWrapper.eq("my_status","在世");


        List<RetiredEmployeesEntity> listAll = baseMapper.listAddPensionExcel(queryWrapper);
        AdjustmentBasisEntity adjustmentBasis = adjustmentBasisService.getInfoList();
        List<RetiredEmployeesEntity> list = new ArrayList<>();
        for (int i = 0; i < listAll.size(); i++) {
            RetiredEmployeesEntity retiredEmployeesEntity = new RetiredEmployeesEntity();
            RetiredEmployeesEntity re =listAll.get(i);


            retiredEmployeesEntity.setPersonalCode(re.getPersonalCode());
            retiredEmployeesEntity.setName(re.getName());
            retiredEmployeesEntity.setSex(re.getSex());
            retiredEmployeesEntity.setBirthDate(re.getBirthDate());
            retiredEmployeesEntity.setWorkTime(re.getWorkTime());
            retiredEmployeesEntity.setRetirementTime(re.getRetirementTime());
            retiredEmployeesEntity.setDuties(re.getDuties());
            retiredEmployeesEntity.setCounty(re.getCounty());
            retiredEmployeesEntity.setStreet(re.getStreet());
            retiredEmployeesEntity.setHandoverPeriod(re.getHandoverPeriod());
            retiredEmployeesEntity.setHandoverTime(re.getHandoverTime());
            retiredEmployeesEntity.setWorkersClassification(re.getWorkersClassification());
            retiredEmployeesEntity.setTotalMonthlyPension(re.getTotalMonthlyPension());
            retiredEmployeesEntity.setExt1(re.getExt1());
            retiredEmployeesEntity.setExt3(re.getExt1()+re.getTotalMonthlyPension());
            retiredEmployeesEntity.setYuYue(adjustmentBasis.getBfys());
            double f = adjustmentBasis.getBfys()*re.getExt1();
            BigDecimal bfj = new BigDecimal(f);
            double bf = bfj.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            retiredEmployeesEntity.setExt2(bf);

            double s = retiredEmployeesEntity.getExt3()+retiredEmployeesEntity.getExt2();
            BigDecimal je = new BigDecimal(s);
            double sf = je.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            retiredEmployeesEntity.setExt4(sf);

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
            Date date = new Date();
            int year = Integer.valueOf(sdf.format(date));
            int birthday = Integer.valueOf(sdf.format(re.getBirthDate()));
            int result = year - birthday;
            retiredEmployeesEntity.setHousingArea(result);

            SimpleDateFormat two = new SimpleDateFormat("yyyy-MM-dd");
            if(re.getWorkTime() != null && re.getRetirementTime() != null)
            {
                String date1 = two.format(re.getWorkTime());
                String date2 = two.format(re.getRetirementTime());
                LocalDate date3 = LocalDate.parse(date1);
                LocalDate date4 = LocalDate.parse(date2);
                int yu = (int)ChronoUnit.MONTHS.between(date3,date4);
                int a = yu / 12;
                int b = yu % 12;
                String pc = a+"年"+b+"月";
                retiredEmployeesEntity.setCommunity(pc);
            }else
            {
                retiredEmployeesEntity.setCommunity("");
            }



            list.add(retiredEmployeesEntity);
        }
        return list;
    }

    @Override
    public void isOver() {
        List<RetiredEmployeesEntity> list =  baseMapper.getData();
        for (int i = 0; i <list.size() ; i++) {
            RetiredEmployeesEntity retiredEmployeesEntity = new RetiredEmployeesEntity();
            retiredEmployeesEntity.setId(list.get(i).getId());
            retiredEmployeesEntity.setTotalMonthlyPension(list.get(i).getExt1()+list.get(i).getTotalMonthlyPension());
            //updateById(retiredEmployeesEntity);
            System.out.println("id:"+list.get(i).getId()+"  数据："+list.get(i).getExt1()+" 月："+list.get(i).getTotalMonthlyPension());
        }
    }

    @Override
    public RetiredEmployeesEntity getDataById(Long id) {
        RetiredEmployeesEntity retiredEmployeesEntity = baseMapper.getDataById(id);
        retiredEmployeesEntity.setExt3(retiredEmployeesEntity.getTotalMonthlyPension()+retiredEmployeesEntity.getExt1());
        retiredEmployeesEntity.setPhone(retiredEmployeesEntity.getCounty()+retiredEmployeesEntity.getStreet());
        retiredEmployeesEntity.setAddress(retiredEmployeesEntity.getCounty());
        Calendar now = Calendar.getInstance();
        String rq = now.get(Calendar.YEAR)+"年"+ (now.get(Calendar.MONTH) + 1) +"月"+now.get(Calendar.DAY_OF_MONTH)+"日";
        retiredEmployeesEntity.setDeath(rq);
        return retiredEmployeesEntity;
    }

    @Override
    public List<RetiredEmployeesEntity> getListAddPensionAll() {
        List<RetiredEmployeesEntity>  listAll = baseMapper.getListAddPensionAll();

        AdjustmentBasisEntity adjustmentBasis = adjustmentBasisService.getInfoList();
        List<RetiredEmployeesEntity> list = new ArrayList<>();
        for (int i = 0; i <listAll.size() ; i++) {
            RetiredEmployeesEntity retiredEmployeesEntity = new RetiredEmployeesEntity();
            RetiredEmployeesEntity re = listAll.get(i);

            //retiredEmployeesEntity.setId(re.getId());
            retiredEmployeesEntity.setPersonalCode(re.getPersonalCode());
            retiredEmployeesEntity.setName(re.getName());
            //retiredEmployeesEntity.setSex(re.getSex());
            retiredEmployeesEntity.setBirthDate(re.getBirthDate());
            retiredEmployeesEntity.setWorkTime(re.getWorkTime());
            retiredEmployeesEntity.setRetirementTime(re.getRetirementTime());
            //retiredEmployeesEntity.setDuties(re.getDuties());
            //retiredEmployeesEntity.setCounty(re.getCounty());
            //retiredEmployeesEntity.setStreet(re.getStreet());
            //retiredEmployeesEntity.setHandoverPeriod(re.getHandoverPeriod());
            //retiredEmployeesEntity.setHandoverTime(re.getHandoverTime());
            //retiredEmployeesEntity.setWorkersClassification(re.getWorkersClassification());
            retiredEmployeesEntity.setTotalMonthlyPension(re.getTotalMonthlyPension());
            retiredEmployeesEntity.setExt1(re.getExt1());
            retiredEmployeesEntity.setExt3(re.getExt1()+re.getTotalMonthlyPension());
            retiredEmployeesEntity.setYuYue(adjustmentBasis.getBfys());
            retiredEmployeesEntity.setExt2(adjustmentBasis.getBfys()*re.getExt1());
            retiredEmployeesEntity.setExt4(retiredEmployeesEntity.getExt3()+retiredEmployeesEntity.getExt2());

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
            Date date = new Date();
            int year = Integer.valueOf(sdf.format(date));
            int birthday = Integer.valueOf(sdf.format(re.getBirthDate()));
            int result = year - birthday;
            retiredEmployeesEntity.setHousingArea(result);

            SimpleDateFormat two = new SimpleDateFormat("yyyy-MM-dd");
            if(re.getWorkTime() != null && re.getRetirementTime() != null)
            {
                String date1 = two.format(re.getWorkTime());
                String date2 = two.format(re.getRetirementTime());
                LocalDate date3 = LocalDate.parse(date1);
                LocalDate date4 = LocalDate.parse(date2);
                int yu = (int)ChronoUnit.MONTHS.between(date3,date4);
                int a = yu / 12;
                int b = yu % 12;
                String pc = a+"年"+b+"月";
                retiredEmployeesEntity.setCommunity(pc);
            }else
            {
                retiredEmployeesEntity.setCommunity("");
            }


            list.add(retiredEmployeesEntity);
        }

        return list;
    }


//    @Overridepper<RetiredEmployeesEntity>().
//                        eq("state",0)
//        );
//        List<RetiredEmployeesEntity> list = new ArrayList<>();
//        for (int i = 0; i <page.getRecords().size() ; i++) {
//            RetiredEmployeesEntity retiredEmployeesEntity = new RetiredEmployeesEntity();
//            RetiredEmployeesEntity re = page.getRecords().get(i);
//            //基本信息
//            retiredEmployeesEntity.setPersonalCode(re.getPersonalCode());
//            retiredEmployeesEntity.setName(re.getName());
//            retiredEmployeesEntity.setTotalMonthlyPension(re.getTotalMonthlyPension());
//            retiredEmployeesEntity.setWorkersClassification(re.getWorkersClassification());
//            retiredEmployeesEntity.setCounty(re.getCounty());
//            retiredEmployeesEntity.setStreet(re.getStreet());
//            retiredEmployeesEntity.setHandoverPeriod(re.getHandoverPeriod());
//            retiredEmployeesEntity.setDeath("错误");
//            //退休费基数
//            Double salaryScale = re.getSalaryScale();//薪级工资
//            Double basicSalary = re.getBasicSalary();//基础工资
//            Double raiseWages = re.getRaiseWages();//提高工资10%
//            Double serviceAllowance = re.getServiceAllowance();//军队服务津贴
//            Double difficultySubsidy = re.getDifficultySubsidy();//困难补助
//            Double gradeSalary = re.getGradeSalary();//岗位工资
//            Double senioritySalary = re.getSenioritySalary();//工龄工资
//            Double levelSalary = re.getLevelSalary();//级别工资
//            Double bonusAllowance = re.getBonusAllowance();//奖金津贴
//            Double seniorityAllowance = re.getSeniorityAllowance();//教护龄津贴
//            Double specialTeacherSubsidy = re.getSpecialTeacherSubsidy();//特级老师补贴
//            //退休费计发比例
//            int txfjfbl = re.getRetirementFeeProportion();
//            //提高比例部分
//            int tgblbf = re.getIncreaseProportion();
//            //工资是否提高10%
//            String gzsftg = re.getIsImprove();
//            int gzsftgValue = 0;
//            if(gzsftg.equals("是"))
//            {
//                gzsftgValue = 10;
//            }
//            txfjfbl = txfjfbl + tgblbf + gzsftgValue;
//
//            Double bl = Double.valueOf(txfjfbl);
//            bl = bl/100;
//            Double sumBasicRe = gradeSalary + salaryScale + serviceAllowance + bonusAllowance + raiseWages + levelSalary;
//            sumBasicRe = Math.ceil(sumBasicRe * bl);
//            sumBasicRe = sumBasicRe + basicSalary + difficultySubsidy + senioritySalary + seniorityAllowance + specialTeacherSubsidy;
//
//            retiredEmployeesEntity.setResultA(Double.valueOf(String.format("%.2f", sumBasicRe )));
//            //历次增加的退休费合计
//            Double retirementPayEightynine = re.getRetirementPayEightynine();//1989年10月增加退休费
//            Double retirementPayNinetyfive = re.getRetirementPayNinetyfive();//1995年10月增加退休费
//            Double retirementPayNinetynisec = re.getRetirementPayNinetynisec();//1999年10月增加退休费
//            Double retirementPayThisec = re.getRetirementPayThisec();//2003年10月增加退休费
//            Double retirementPayFirst = re.getRetirementPayFirst();//1993年10月第一步增加退休费
//            Double retirementPayNinetyseven = re.getRetirementPayNinetyseven();//1997年7月增加退休费
//            Double retirementPayOne = re.getRetirementPayOne();//2001年1月增加退休费
//            Double retirementPayThird = re.getRetirementPayThird();//2003年7月增加退休费
//            Double retirementPayFourty = re.getRetirementPayFourty();//2014年10月增加退休费
//            Double retirementPayNinetytwo = re.getRetirementPayNinetytwo();//1992年3月提高退休费10％
//            Double retirementPayNinetysesec = re.getRetirementPayNinetysesec();//1997年10月增加退休费
//            Double retirementPayOnsec = re.getRetirementPayOnsec();//2001年10月增加退休费
//            Double retirementPayFive = re.getRetirementPayFive();//2005年10月增加退休费
//            Double retirementPaySecond = re.getRetirementPaySecond();//1993年10月第二步增加退休费
//            Double retirementPayNinetynine = re.getRetirementPayNinetynine();//1999年7月增加退休费
//            Double retirementPayOnenew = re.getRetirementPayOnenew();//2001年10月新增退休费
//            Double retirementPaySix = re.getRetirementPaySix();//2006年7月增加退休费
//            Double sumAddRe = retirementPayEightynine+retirementPayNinetyfive+retirementPayNinetynisec+retirementPayThisec+retirementPayFirst+
//                    retirementPayNinetyseven+retirementPayOne+retirementPayThird+retirementPayFourty+retirementPayNinetytwo+retirementPayNinetysesec+
//                    retirementPayOnsec+retirementPayFive+retirementPaySecond+retirementPayNinetynine+retirementPayOnenew+retirementPaySix;//历次增加的退休费合计
//            retiredEmployeesEntity.setResultB(Double.valueOf(String.format("%.2f", sumAddRe )));
//            //价格生活补贴合计
//            Double foodAllowanceSeventynine = re.getFoodAllowanceSeventynine();
//            Double oilAllowanceNightyone = re.getOilAllowanceNightyone();
//            Double fuelLlowance = re.getFuelLlowance();
//            Double oilAllowanceNightythird = re.getOilAllowanceNightythird();
//            Double livingAllowanceEightyei = re.getLivingAllowanceEightyei();
//            Double livingAllowanceNightyfo = re.getLivingAllowanceNightyfo();
//            Double foodAllowanceEightyeight = re.getFoodAllowanceEightyeight();
//            Double oilAllowanceNightytwo = re.getOilAllowanceNightytwo();
//            Double meatLlowance = re.getMeatLlowance();
//            Double livingAllowanceEightyfive = re.getLivingAllowanceEightyfive();
//            Double livingAllowanceNightytw = re.getLivingAllowanceNightytw();
//            Double livingAllowanceNightyfive = re.getLivingAllowanceNightyfive();
//            Double sumPrice = foodAllowanceSeventynine + oilAllowanceNightyone + fuelLlowance + oilAllowanceNightythird +
//                    livingAllowanceEightyei + livingAllowanceNightyfo + foodAllowanceEightyeight +
//                    oilAllowanceNightytwo + meatLlowance + livingAllowanceEightyfive + livingAllowanceNightytw + livingAllowanceNightyfive;//价格生活补贴合计
//            retiredEmployeesEntity.setResultC(Double.valueOf(String.format("%.2f", sumPrice )));
//            //增加生活机制（补贴）合计
//            Double livingAllowanceSeven = re.getLivingAllowanceSeven();
//            Double jobSubsidy = re.getJobSubsidy();
//            Double ageAllowance = re.getAgeAllowance();
//            Double retirementAllowanceOneo = re.getRetirementAllowanceOneo();
//            Double workingYearsSubsidy = re.getWorkingYearsSubsidy();
//            Double proportionalSubsidy = re.getProportionalSubsidy();
//            Double growthMechanismThirty = re.getGrowthMechanismThirty();
//            Double retirementAllowanceOneth = re.getRetirementAllowanceOneth();
//            Double retirementAllowanceThirty = re.getRetirementAllowanceThirty();
//            Double pensionSixteen = re.getPensionSixteen();
//            Double pensionSeventeen = re.getPensionSeventeen();
//            Double pensionEighteen = re.getPensionEighteen();
//            Double pensionNineteen = re.getPensionNineteen();
//            Double adjustTreatment = re.getAdjustTreatment();
//            Double pensionTwenty = re.getPensionTwenty();
//            Double pensionTwentyone = re.getPensionTwentyone();
//            Double sumMeleft = livingAllowanceSeven + jobSubsidy + ageAllowance + retirementAllowanceOneo + workingYearsSubsidy + proportionalSubsidy +
//                    growthMechanismThirty + retirementAllowanceOneth + retirementAllowanceThirty + pensionSixteen + pensionSeventeen + pensionEighteen +
//                    pensionNineteen + adjustTreatment + pensionTwenty + pensionTwentyone;
//            retiredEmployeesEntity.setResultF(Double.valueOf(String.format("%.2f", sumMeleft )));
//            //其它合计
//            Double paperMoney = re.getPaperMoney();
//            Double bathSubsidy = re.getBathSubsidy();
//            Double housingSubsidy = re.getHousingSubsidy();
//            Double otherIncome = re.getOtherIncome();
//            Double honorAllowance = re.getHonorAllowance();
//            Double serviceSubsidy = re.getServiceSubsidy();
//            Double sumOther = paperMoney + bathSubsidy + housingSubsidy + otherIncome + honorAllowance + serviceSubsidy;
//            retiredEmployeesEntity.setResultG(Double.valueOf(String.format("%.2f", sumOther )));
//            //自动生成退休费
//            Double sum = sumBasicRe + sumAddRe + sumPrice + sumMeleft + sumOther;
//            retiredEmployeesEntity.setResultH(Double.valueOf(String.format("%.2f", sum)));
//            //退休费的差额
//            Double total = re.getTotalMonthlyPension();
//            Double sumC = total - sum;
//            retiredEmployeesEntity.setResultI(Double.valueOf(String.format("%.2f", sumC)));
//            if(sumC >0 || sumC <0)
//            {
//                list.add(retiredEmployeesEntity);
//            }
//
//        }
//        page.setRecords(list);
//        return new PageUtils(page);
//    }

    @Override
    public PageUtils queryRepeatPage(Map<String, Object> params) {
        IPage<RetiredEmployeesEntity> page = null;
        List<String> list = baseMapper.queryRepeatList();
        if(list.size() > 0)
        {
            page = this.page(
                    new Query<RetiredEmployeesEntity>().getPage(params),
                    new QueryWrapper<RetiredEmployeesEntity>().
                            eq("state",0).in("personal_code",list).orderByAsc("personal_code")
            );
        }else
        {
            page = this.page(
                    new Query<RetiredEmployeesEntity>().getPage(params),
                    new QueryWrapper<RetiredEmployeesEntity>().
                            eq("state",3)
            );
        }


        return new PageUtils(page);
    }

    @Override
    public PageUtils queryDeathPage(Map<String, Object> params) {
        String deathTime1 = (String)params.get("deathTime1");
        String deathTime2 = (String)params.get("deathTime2");
        String logoutDate1 = (String)params.get("logoutDate1");
        String logoutDate2 = (String)params.get("logoutDate2");
        String county = (String)params.get("county");
        String street = (String)params.get("street");

        IPage<RetiredEmployeesEntity> page = this.page(
                new Query<RetiredEmployeesEntity>().getPage(params),
                new QueryWrapper<RetiredEmployeesEntity>().
                        eq("state",0).eq("my_status","死亡").
                        eq(StringUtils.isNotBlank(county),"county", county).
                        eq(StringUtils.isNotBlank(street),"street", street).
                        ge(StringUtils.isNotBlank(deathTime1),"death_time", deathTime1).
                        le(StringUtils.isNotBlank(deathTime2),"death_time", deathTime2).
                        ge(StringUtils.isNotBlank(logoutDate1),"logout_date", logoutDate1).
                        le(StringUtils.isNotBlank(logoutDate2),"logout_date", logoutDate2)
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils searchDeathPage(Map<String, Object> params) {
        String deathTime1 = (String)params.get("deathTime1");
        String deathTime2 = (String)params.get("deathTime2");
        String logoutDate1 = (String)params.get("logoutDate1");
        String logoutDate2 = (String)params.get("logoutDate2");
        String county = (String)params.get("county");
        String street = (String)params.get("street");

        IPage<RetiredEmployeesEntity> page = this.page(
                new Query<RetiredEmployeesEntity>().getPage(params),
                new QueryWrapper<RetiredEmployeesEntity>().
                        eq("state",0).eq("my_status","死亡").
                        eq(StringUtils.isNotBlank(county),"county", county).
                        eq(StringUtils.isNotBlank(street),"street", street).
                        ge(StringUtils.isNotBlank(deathTime1),"death_time", deathTime1).
                        le(StringUtils.isNotBlank(deathTime2),"death_time", deathTime2).
                        ge(StringUtils.isNotBlank(logoutDate1),"logout_date", logoutDate1).
                        le(StringUtils.isNotBlank(logoutDate2),"logout_date", logoutDate2)
        );

        return new PageUtils(page);
    }


    @Override
    public List<RetiredEmployeesEntity> listDeathExcel(Map<String, Object> params) {
        String deathTime1 = (String)params.get("deathTime1");
        String deathTime2 = (String)params.get("deathTime2");
        String logoutDate1 = (String)params.get("logoutDate1");
        String logoutDate2 = (String)params.get("logoutDate2");
        String county = (String)params.get("county");
        String street = (String)params.get("street");

        QueryWrapper<RetiredEmployeesEntity>  queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("state",0);
        queryWrapper.eq("my_status","死亡");
        queryWrapper.eq(StringUtils.isNotBlank(county),"county", county);
        queryWrapper.eq(StringUtils.isNotBlank(street),"street", street);
        queryWrapper.ge(StringUtils.isNotBlank(deathTime1),"death_time", deathTime1);
        queryWrapper.le(StringUtils.isNotBlank(deathTime2),"death_time", deathTime2);
        queryWrapper.ge(StringUtils.isNotBlank(logoutDate1),"logout_date", logoutDate1);
        queryWrapper.le(StringUtils.isNotBlank(logoutDate2),"logout_date", logoutDate2);

        return baseMapper.listDeathExcel(queryWrapper);
    }

    @Override
    public List<RetiredEmployeesEntity> getStreetByContry(String contrys) {
        return baseMapper.getStreetByContry(contrys);
    }

    @Override
    public PageUtils queryDeletePage(Map<String, Object> params) {
        String personalCode = (String)params.get("personalCode");
        String name = (String)params.get("name");
        String idNo = (String)params.get("idNo");


        IPage<RetiredEmployeesEntity> page = this.page(
                new Query<RetiredEmployeesEntity>().getPage(params),
                new QueryWrapper<RetiredEmployeesEntity>().
                        eq("state",1).
                        eq(StringUtils.isNotBlank(personalCode),"personal_code", personalCode).
                        eq(StringUtils.isNotBlank(name),"name", name).
                        eq(StringUtils.isNotBlank(idNo),"id_no", idNo)
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils searchDeletePage(Map<String, Object> params) {
        String personalCode = (String)params.get("personalCode");
        String name = (String)params.get("name");
        String idNo = (String)params.get("idNo");


        IPage<RetiredEmployeesEntity> page = this.page(
                new Query<RetiredEmployeesEntity>().getPage(params),
                new QueryWrapper<RetiredEmployeesEntity>().
                        eq("state",1).
                        eq(StringUtils.isNotBlank(personalCode),"personal_code", personalCode).
                        eq(StringUtils.isNotBlank(name),"name", name).
                        eq(StringUtils.isNotBlank(idNo),"id_no", idNo)
        );

        return new PageUtils(page);
    }

    @Override
    public void recoveryById(Long[] ids) {
        baseMapper.recoveryById(ids);
    }



    @Override
    public List<RetiredEmployeesEntity> getName(String query) {
        return baseMapper.getName(query);
    }

    @Override
    public void removeByState(Long[] ids) {
        baseMapper.removeByState(ids);
    }

    @Override
    public List<RetiredEmployeesEntity> getTypeNum(String type,String area) {
        if(type.equals("BRZT"))
        {
            return baseMapper.getTypeNum(area);
        }else if(type.equals("ZZMM")){
            return baseMapper.getZzmmNum(area);
        }else if(type.equals("NATION")){
            return baseMapper.getNationNum(area);
        }else if(type.equals("SEX_GROUP")){
            return baseMapper.getSexNum(area);
        }else if(type.equals("TXQSF")){
            return baseMapper.getTxqsfNum(area);
        }else if(type.equals("TXSZW")){
            return baseMapper.getTxqzwNum(area);
        }else if(type.equals("EMPLOYEE")){
            return baseMapper.getEmployeeNum(area);
        }else if(type.equals("YJSJD")){
            return baseMapper.getYjsjdNum(area);
        }else if(type.equals("YBD")){
            return baseMapper.getYbdNum(area);
        }else if(type.equals("STREET")){
            return baseMapper.getStreetNum(area);
        }else if(type.equals("AREA")){
            return baseMapper.getAreaNum(area);
        }
        return null;
    }
}
